//
//  AXBtnCell.m
//  爱鲜蜂
//
//  Created by HH on 16/11/22.
//  Copyright © 2016年 胡浩. All rights reserved.
//

#import "AXFBtnCell.h"
#import "AXFCommonModel.h"

@interface AXFBtnCell ()

@property (nonatomic,weak)UIImageView *pictureView;

@property (nonatomic,weak)UILabel *label;

@end

@implementation AXFBtnCell

- (void)setupUI
{
//    UIButton *displayBtn = [[UIButton alloc] init];
//    
//    self.displayBtn = displayBtn;
//    
//    [self.contentView addSubview:displayBtn];
    
    UIImageView *pictureView = [[UIImageView alloc] init];
    
    self.pictureView = pictureView;
    
    pictureView.contentMode = UIViewContentModeScaleAspectFill;
    
    [self.contentView addSubview:pictureView];
    
    UILabel *label = [[UILabel alloc] init];
    
    self.label = label;
    
    label.font = [UIFont systemFontOfSize:12];
    
    [self.contentView addSubview:label];
    
    [pictureView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(46, 46));
    }];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(pictureView.mas_bottom).offset(5);
        make.centerX.equalTo(self.contentView);
    }];
    
}


//- (UIButton *)createButtonWithImageName:(NSString *)imageName tittle:(NSString *)tittle andTag:(NSInteger)tag
//{
//    UIButton *btn = [[UIButton alloc] init];
//    //利用老师给的分类,创建图文混排的按钮(图片转换成文字格式来显示)
//    [btn setAttributedTitle:[NSAttributedString cz_imageTextWithImage:[UIImage imageNamed:imageName] imageWH:32 title:tittle fontSize:12 titleColor:[UIColor cz_colorWithHex:0x181818] spacing:13] forState:UIControlStateNormal];
//    //    btn.titleLabel.font = [UIFont systemFontOfSize:12 weight:15];
//    btn.titleLabel.numberOfLines = 0;
//    btn.tag = tag;
//    btn.titleLabel.textAlignment = NSTextAlignmentCenter;
//    [btn sizeToFit];//要自适应!!!!!!!!!,要不没大小!!!!然后就不显示了
//    [btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:btn];
//    return btn;
//}
//
//- (void)clickBtn:(UIButton *)sender
//{
//    
//}

//- (void)setDict:(NSDictionary *)dict
//{
//    _dict = dict;
//    
//    AXFCommonModel *model = [AXFCommonModel yy_modelWithDictionary:dict];
//    
//    [self.pictureView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"v2_placeholder_square"]];
//    
//    self.label.text = model.name;
//}

- (void)setModel:(AXFCommonModel *)model
{
    _model = model;
    
    [self.pictureView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"v2_placeholder_square"]];
    
    self.label.text = model.name;
}

@end
